<style>
    .baseInp{height: 24px; padding: 5px;border: 1px solid #C9C9C9;-moz-box-shadow: 0px 1px 1px rgba(0,0,0,.08) inset;-webkit-box-shadow: 0px 1px 1px rgba(0,0,0,.08) inset;box-shadow: 0px 1px 1px rgba(0,0,0,.08) inset;border-radius: 2px 0 0 2px;-moz-border-radius: 2px 0 0 2px;}
    .baseInp:focus{color: #0797D9; border-color: #0797D9;}
    .w300{width: 300px;}
    
    .rtWrap{width:800px; float:right;}
    .rtWrap .formIn{width: 768px; border: 1px solid #E5E5E5 ; padding: 20px 15px; position: relative;}
    .rtWrap .formIn .iSerhBtn{height: 36px; width: 100px; border: 0 none; margin-left: -4px;  background: #0797D9; color: #FFFFFF; cursor: pointer; border-radius: 0 2px 2px 0; -moz-border-radius: 0 2px 2px 0;}
    .rtWrap .formIn .iSerhBtn:active{background: #0A84BC;}
    .rtWrap .formIn .del{position: absolute; left: 305px; top: 27px; text-decoration: none;}

    .tbbox{width: 100%;}
    .tb_show{table-layout:fixed;width:100%;font-size:12px;border-top:1px solid #E5E5E5;border-left:1px solid #E5E5E5;}
    .tb_show td,.tb_show th{border-bottom:1px solid #E5E5E5;border-right:1px solid #E5E5E5;text-align:center;}
    .tb_show th{background-color: #dbebf1;height:35px;line-height:35px;font-weight: normal;color:#4F4F4F;}
    .tb_show .setalign{text-align:left;padding-left:10px;}
    .tb_show td{background:#F1F1F1;height:40px;line-height:40px;color:#6D6B6B}
    .tb_show .setbg td{background:#FFF;color:#948E8E;}
    .setwidth_a{width:75px;}
    .setwidth_b{width:100px;}
    .setwidth_c{width:85px;}
    .operate{display:inline-block;width:0;height:0;vertical-align:middle;border:6px solid #FFF;
        border-bottom-width:0;border-top-color:#707070;margin-left:5px;}
    .on{border: 6px solid #FFF;border-top-width:0;border-bottom-color:#5B5B5B;}
    .msg{background:#FFF;border:1px solid #CCC;font-size:12px;display:inline-block;width:55px;height:20px;line-height:20px;text-align:center;}
    .setclick{cursor:pointer;}
    .tb_show .setheight{line-height:18px;padding:2px 0;}
</style>
<div class="rtWrap">
    <div class="formIn">
        <input class="baseInp w300" type="text" value="<?=safetxt($_GET['land'])?>"/>
        <a class="iconfont del" href="http://www.12301.cc/terminal_share_list_new.html">&#xe627;</a>
        <button class="iSerhBtn">搜索</button>
    </div>
    <div class="tbbox">
        <table class="tb_show" border="0" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th class="setalign">景点</th>
                    <th class="setwidth_a">旧终端号</th>
                    <th class="setwidth_b">终端号(合并后)</th>
                    <th class="setwidth_a">旧SalerID</th>
                    <th class="setwidth_b">SalerID(合并后)</th>
                    <th class="setwidth_c">添加时间</th>
                    <th class="setwidth_a">操作人ID</th>
                    <th class="setwidth_a">操作</th>
                </tr>
            </thead>
            <?foreach($data as $list):?>
                <tbody id="tbody_<?=$list['nowSalerID']?>">
                    <tr class="setbg" id="<?=$list['id']?>">
                        <td class="setalign" data-id="<?=$list['nowSalerID']?>"><span class="setclick"><?=$list['title']?><em class="operate"></em></span></td>
                        <td><?=$list['preTerminal']?></td>
                        <td><?=$list['nowTerminal']?></td>
                        <td><?=$list['preSalerID']?></td>
                        <td><?=$list['nowSalerID']?></td>
                        <td class="setheight"><?=$list['addtime']?></td>
                        <td><?=$list['privID']?></td>
                        <td></td>
                    </tr>
                </tbody>
            <?php endforeach?>
        </table>
    </div>
</div>
<script>
    $(document).ready(function(){
        $("table").on('click', '.cancel_merged', function(){
            if (!confirm('您确定要取消合并吗？')) return false;
            var id = $(this).data('id');
            $.post('terminal_share_list.html', {action:'cancel_merged', id:id}, function(ret){
                if (ret==1) alert('操作成功!');
                else alert('操作失败！');
            });
        });
        $("table").on('click', '.setclick', function(){
            var salerid=$(this).parents('td').data('id'),_this = $(this);
            if (!$(this).hasClass('pulled')) {
                $.getJSON(
                    'terminal_share_list.html',
                    {
                        action:'get_merged',
                        salerid:salerid
                    },
                    function(json) {
                        var html = '';
                        for (var i in json) {
                            html += '<tr class="tr_'+salerid+'">' +
                                '<td>'+json[i]['title']+'</td>' +
                                '<td>'+json[i]['preTerminal']+'</td>' +
                                '<td>'+json[i]['nowTerminal']+'</td>' +
                                '<td>'+json[i]['preSalerID']+'</td>' +
                                '<td>'+json[i]['nowSalerID']+'</td>' +
                                '<td>'+json[i]['addtime']+'</td>' +
                                '<td>'+json[i]['privID']+'</td>' +
                                '<td><a class="cancel_merged" data-id="'+json[i]['id']+'" href="javascript:;">取消合并</a></td>' +
                                '</tr>';
                        }
                        _this.addClass('pulled open');
                        $("#tbody_"+salerid).append(html);
                    }
                );
                return true;
            }
            if (_this.hasClass('open')) {
                $(".tr_"+salerid).hide();
                _this.removeClass('open');
            } else {
                _this.addClass('open');
                $(".tr_"+salerid).show();
            }
        });

        $(".baseInp").on("keydown", function(event) {
            if (event.keyCode == 13) {
                $(".iSerhBtn").trigger("click");
            }
        })

        $(".baseInp").bind("input propertychange", function() {
            $(".setbg").each(function(index) {
                var title = $(this).find("td").eq(0).text();
                if (title.indexOf($(".baseInp").val()) < 0) {
                    $(this).hide();
                } else {
                    $(this).show();
                }
            })
        })
        
        $(".iSerhBtn").on("click", function() {
            var keyword = $(".baseInp").val();
            var url = "http://www.12301.cc/terminal_share_list_new.html"
            if ($.trim(keyword) == '') {
                window.location.href = url;
                return ;
            }
            window.location.href = url + "?land=" + keyword;
        })
    });
</script>